/*
 * @Author: csh
 * @Date: 2022-07-27
 * @LastEditors: BigFlower
 * @LastEditTime: 2022-10-11 21:25:25
 * @Description: file content
 * @FilePath: \wochat-vue3-ts-pinia\vite.config.ts
 */
import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import legacy from "@vitejs/plugin-legacy";
import path from "path";

// https://vitejs.dev/config/
export default defineConfig({
  resolve: {
    //设置别名
    alias: {
      "@": path.resolve(__dirname, "src"),
    },
  },
  plugins: [
    vue(),
    legacy({
      targets: ["defaults", "chrome > 58"],
    }),
  ],
  server: {
    host: "0.0.0.0",
    port: 8080, //启动端口
    hmr: {
      host: "127.0.0.1",
      port: 8080,
    },
    // // 设置 https 代理
    // proxy: {
    //   "/api": {
    //     target: "your https address",
    //     changeOrigin: true,
    //     rewrite: (path: string) => path.replace(/^\/api/, ""),
    //   },
    // },
  },
  // base: "/",
  base: process.env.NODE_ENV === "production" ? "/wochat-vue3-ts-pinia/" : "/",
  publicDir: "src/public", // 静态资源服务的文件夹
});
